var User = require('mongoose').model('user')
module.exports = {
  addUser: async (param) => {
    try {
      var user = await User.create(param)
      console.log('添加成功', user)
      return user;
    } catch (error) {
      console.log(error)
    }
  },
  update: async (param) => {
    var oldData = param.oldData;
    var newData = param.newData;
    const res = await User.update(oldData, newData)
    console.log(res)
    return res
  },
  delete: async (param) => {
    param ? param : {}
    return await User.remove(param)
  },
  get: async (ctx, next) => {
    const param = ctx.request.body || {}
    var result = await User.find(param)
    ctx.body = result
    next()
  }
}